const express =require('express');
const data = require('../data/newdata.json');
const r = express.Router();

r.get('/',(req,res)=>{
    res.render('index.ejs',{username:"小李"});
});

r.get('/list',(req,res)=>{
    res.render('list.ejs',{data});
});

r.get('/detail/:id',(req,res)=>{
    let {id} = req.params;
    let {newsTitle,newsContent} = data.find(item=>item.id===id)
    res.render('detail.ejs',{newsTitle,newsContent});
});

module.exports = r;